<?php
defined('IN_YuLin') || exit('NO PERMIT!');



$sql = "SELECT u.username,ml.dateline,b.name,
		c.orderid,c.bankcard,c.notes,c.truename,c.money,
		CASE c.status
			WHEN 0 THEN
				'审核'
			WHEN 1 THEN
				'提现成功'
			ELSE
				'提现失败'
		END AS status
		FROM yulin_user_money_log AS ml
		LEFT JOIN yulin_user AS u
		ON ml.uid = u.id
		LEFT JOIN yulin_user_money_cash AS c
		on ml.lkey= CONCAT('cash_',c.orderid)
		LEFT JOIN yulin_web_bank AS b
		ON c.bank = b.id
		WHERE ml.tid = 'cash'";

$where = "";
$username = NoBadStr($_GET['username']);
$username && $where .= " and u.username = '".$username."'";

$lkey = NoBadStr($_GET['lkey']);
$lkey && $where .= " and c.orderid = '".$lkey."'";

$begintime = NoBadStr($_GET['begintime']);
$begintime && $where .= " and ml.dateline > '".strtotime($begintime)."'";

$endtime = NoBadStr($_GET['endtime']);
$endtime && $where .= " and ml.endtime > '".strtotime($endtime)."'";

$sql .= $where;
$rows = $db->affected_rows($sql);

if($rows){
	$page = max(1,intval($_GET['page']));
	$size = 20;
	$url = "?m=".$m."&c=".$c."&a=".$a."&username=".$username."&lkey=".$lkey."&begintime=".$begintime."&endtime=".$endtime;

	$sql .= " ORDER BY ml.id DESC LIMIT ".($page - 1) * $size.", ".$size;
	$data = $db->getall($sql);
	$multi = Multi($url, $page, $rows, $size);
}

$tpl->display($m.'/'.$c);
